import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class testCollections {
    @Test
    public void testSort() {
        List<String> list = new ArrayList<String>();
        list.add("c");
        list.add("d");
        list.add("b");
        list.add("a");
        Collections.sort(list);

        System.out.println(list);
    }

    @Test
    public void testReverse() {
        List<String> list = Arrays.asList("a b c d e f".split(" "));
        Collections.reverse(list);

        System.out.println(list);
    }

    @Test
    public void testShuffle() {
        List<String> list = new ArrayList<String>();
        list.add("c");
        list.add("d");
        list.add("b");
        list.add("a");
        Collections.shuffle(list);
        System.out.println(list);
    }

    @Test
    public void testFill() {
        List<String> list = Arrays.asList("a b c d e f".split(" "));
        System.out.println(list);
        Collections.fill(list, "我");

        System.out.println(list);
    }

    @Test
    public void testCopy() {
        List<String> m = Arrays.asList("a b c d e f".split(" "));
        List<String> n = Arrays.asList("我 我 我".split(" "));
        Collections.copy(m, n);
        System.out.println(m);
    }

    @Test
    public void testMin() {
        List<String> list = Arrays.asList("a b c d e f".split(" "));
        System.out.println(Collections.max(list));
    }

    @Test
    public void testIndexOfSubList() {
        List<String> m = Arrays.asList("a b b c b d e f".split(" "));
        List<String> n = Arrays.asList("b b c".split(" "));
        System.out.println(Collections.indexOfSubList(m, n));
    }

    @Test
    public void testLastIndexOfSubList() {
        List<String> m = Arrays.asList("a b b c b c d e f".split(" "));
        List<String> n = Arrays.asList("b c".split(" "));

        System.out.println(Collections.indexOfSubList(m, n));
        System.out.println(Collections.lastIndexOfSubList(m, n));
    }

    @Test
    public void testRotate() {
        List<String> list = Arrays.asList("a b c d e f".split(" "));
        Collections.rotate(list, 1);
        System.out.println(list);
        Collections.rotate(list, -1);
        System.out.println(list);
    }

    @Test
    public void testSwap() {
        List<String> list = Arrays.asList("a b c d e f".split(" "));
        Collections.swap(list, 2, 3);
        System.out.println(list);
    }

    @Test
    public void testBinarySearch() {
        List<String> list = Arrays.asList("a b c d e f".split(" "));
        int index = Collections.binarySearch(list, "d");
        System.out.println(index);
    }

    @Test
    public void testReplaceAll() {
        List<String> list = Arrays.asList("a b c d e f".split(" "));
        System.out.println(Collections.replaceAll(list, "e", "我"));
        System.out.println(Collections.replaceAll(list, "ee", "我"));
        System.out.println(list);
    }

    @Test
    public void testSynchronizedList() {
        List list = new ArrayList();
        List list1 = Collections.synchronizedList(list);
    }
}

